<!--
<template>
  <div>


&lt;!&ndash;头部导航栏&ndash;&gt;
    <div>
      <b-navbar toggleable="lg" type="dark" variant="info">
        <b-navbar-brand >鲜花之都</b-navbar-brand>
        <mu-flex justify-content="center">
          <Icon>欢迎{{user.username}}</Icon>
          <div v-show="true">
             <Button  @click="openSimple =true">登录</Button>
          </div>



     &lt;!&ndash;     <Button type="text" to="/manage">鲜花管理</Button>
          <Button type="text" to="/houtai">上传</Button>&ndash;&gt;
        </mu-flex>
        <mu-dialog title="登录" width="360" :open.sync="openSimple">
          <Input style="padding: 15px" v-model="user.username" type="text" name="username" placeholder="请输入账号...."/>
          <Input style="padding: 15px" type="password" v-model="user.password" name="password" placeholder="请输入密码...."/>

            <Button :loading="loading"  @click="login" type="info">登录</Button>

            <Button type="text" style="float: right" @click="zhucer1">没有账号？请先注册</Button>

          <mu-dialog title="注册" width="360" :open.sync="zhucer">
            <span>账号</span>
            <Input v-model="user.username"/>
            <span>密码</span>
            <Input type="password" v-model="user.password"/>
            <br>
            <Button type="info" style="margin: 5px" @click="setUser">提交</Button>
          </mu-dialog>
        </mu-dialog>
        <b-collapse id="nav-collapse" is-nav>
          <b-navbar-nav class="ml-auto">
            <b-nav-form>
              <b-form-input size="sm" class="mr-sm-2" placeholder="..." ></b-form-input>
              <b-button size="sm" class="my-2 my-sm-0" type="submit" >搜索</b-button>
            </b-nav-form>

            <b-nav-item-dropdown text="Lang" right>
              <b-dropdown-item href="#">EN</b-dropdown-item>
              <b-dropdown-item href="#">ES</b-dropdown-item>
              <b-dropdown-item href="#">RU</b-dropdown-item>
              <b-dropdown-item href="#">FA</b-dropdown-item>
            </b-nav-item-dropdown>

            <b-nav-item-dropdown right>
              <template v-slot:button-content>
                <em>User</em>
              </template>
              <b-dropdown-item href="#">Profile</b-dropdown-item>
              <b-dropdown-item @click="logOut" href="#">退出登录</b-dropdown-item>
            </b-nav-item-dropdown>
          </b-navbar-nav>
        </b-collapse>
      </b-navbar>
    </div>
    <br>

    &lt;!&ndash;中间内容&ndash;&gt;
    <Row>
      <Content>
        <router-view></router-view>
      </Content>
    </Row>

  </div>
</template>

<script>
export default {
  name: "index",
  data(){
    return {

      management:null,
      openSimpleDialog:false,
      openSimple: false,
      zhucer:false,
      user: {
        username: null,
        password: null
      },
      loginStatusFlag:true
    };
  },
  methods: {

    openSimpleDialog () {
      this.openSimple = true;
    },
    login() {
      this.axios.post("/lgoin",this.qs.stringify(this.user)).then((res)=>{
        if (res.data){
          this.openSimple = false
          this.loginStatusFlag = true
          this.$message.success('登录成功')
          sessionStorage.setItem("username",res.data.username)
       //   this.$router.push({path:'/index',params:{id:res.data.username}})
        }else{
          this.$Message.error('账号或密码有误！！！')
        }
      })

    },
    zhucer1(){
      this.zhucer =true
    },
    setUser(){
      this.axios.post("/setUser",this.qs.stringify(this.user)).then(res=>{
        if (res.data){
          this.$message.success('注册成功')
        }else{
          this.$message.error('注册失败')
        }
      })
    },
    logOut(){
      this.loginStatusFlag = false
    }
  },
  mounted() {
   if(sessionStorage.getItem("username")!=null){

   }
  }
}
</script>
<style scoped>
</style>-->
<template>
  <div >
  <Menu mode="horizontal" :theme="theme1" active-name="1">
    <MenuItem v-if="!loginstatus" @click.native="login" name="1">
      <Icon type="ios-paper" to="/" />
      登录
    </MenuItem>
    <MenuItem v-if="loginstatus" @click.native="logout" name="1">
      <Icon type="ios-paper" />
       退出
    </MenuItem>
    <Submenu v-if="loginstatus" name="3">
      <template slot="title">
        <Icon type="ios-stats" />
        {{loginstatus?user.compellation:""}},我的
      </template>
      <MenuGroup v-if="user.username=='admin'" title="admin">
        <MenuItem name="3-1" @click.native="dialogVisible=true">鲜花管理</MenuItem>
        <MenuItem name="3-2">订单管理</MenuItem>
        <MenuItem name="3-3">留言管理</MenuItem>
      </MenuGroup>
      <MenuGroup v-else :title="user.compellation">
        <MenuItem name="3-4" to="/aaa">我的信息</MenuItem>
        <MenuItem name="3-5" to="/hhh">购物车</MenuItem>
        <MenuItem name="3-6">我的订单</MenuItem>
        <MenuItem name="3-7">收藏</MenuItem>
      </MenuGroup>
    </Submenu>
  </Menu>

    <el-dialog
        title="鲜花管理"
        :visible.sync="dialogVisible"
        width="70%"
        :before-close="handleClose">

      <Button type="info" @click.native="dialogVisible2=true">增加鲜花</Button>

      <!--              增加鲜花      -->
      <mu-dialog title="增加鲜花" width="40%"  :open.sync="dialogVisible2" >
        <div style="padding: 50px;margin: 35px" >
          <label>鲜花名称  :</label>
          <Input  v-model="flower.flowers" placeholder="请输入鲜花名称..." style="width: auto" /><br>
          <label>鲜花简介  :</label>
          <Input type="textarea" v-model="flower.synopsis"  placeholder="请输入鲜花详情介绍" style="width: auto" /><br>

          <label>鲜花上传时间  :</label>
          <DatePicker type="date" v-model="flower.flowerDate"   placeholder="鲜花上传时间" style="width: 200px"></DatePicker>
          <br>
          <label>鲜花价钱  :</label>
          <Input  placeholder="请输入价钱" v-model="flower.price" style="width: auto" /><br>
          <label>鲜花分类  :</label>
          <Select style="width:200px" v-model="flower.flowerById">
            <Option v-for="item in flowersID" :value="item.value" :key="item.value">{{ item.value }}</Option>
          </Select><br>
          <label>鲜花图片路径  :</label>
          <Upload
              multiple
              type="drag"
              action="upload"
              v-model="flower.picture">
            <div style="padding: 20px 0">
              <Icon type="ios-cloud-upload" size="52" style="color: #3399ff"></Icon>
              <p>Click or drag files here to upload</p>
            </div>
          </Upload><br>
        </div>
        <mu-button slot="actions" flat color="primary" @click="uploading">提交</mu-button>
      </mu-dialog>



      <el-table
          :data="tableData"
          style="width: 100%">
        <el-table-column
            label="鲜花名称"
            width="180">
          <template slot-scope="scope">
            玫瑰花
          </template>
        </el-table-column>
        <el-table-column
            label="日期"
            width="180">
          <template slot-scope="scope">
            <el-popover trigger="hover" placement="top">
             2020-09-29
            </el-popover>
          </template>
        </el-table-column>
        <el-table-column label="操作">
          <template slot-scope="scope">
            <el-button
                size="mini"
                @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
            <el-button
                size="mini"
                type="danger"
                @click="handleDelete(scope.$index, scope.row)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>





      <span slot="footer" class="dialog-footer">
    <el-button @click="dialogVisible = false">取 消</el-button>
    <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
  </span>
    </el-dialog>


  <login :loginmodal = "loginmodal"   @passByValue="passByValue"></login>
    <Content>
      <router-view></router-view>
    </Content>
  </div>
</template>
<script>

  import login from '_c/login'
  export default {
    data () {
      return {
        date2:null,
        theme1: 'dark',
        loginstatus:false,
        dialogVisible2: false,
        loginmodal:false,
        dialogVisible: false,//鲜花管理对话框控制
        tableData: [{
          date: '2016-05-02',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1518 弄'
        }],
        flower:{
          flowers:null,// 鲜花名称
          synopsis: null,//鲜花简介
          picture:null,//鲜花图片路径
          flowerDate:null,//鲜花上传时间
          price:null, //鲜花价钱
          flowerById:null,
        },
        flowersID: //鲜花分类
            [{
              value: '玫瑰花'
            },{
              value: "水仙花"
            },
              {
                value: '百合'
              },{
              value: "康乃馨"
            }]
      }
    },methods:{
      date1(){
        alert(date2)
      },
      handleClose(done) {
        this.$confirm('确认关闭？')
            .then(_ => {
              done();
            })
            .catch(_ => {});
      },
      login(){
        this.loginmodal = true
      },
      logout(){
        this.loginstatus = false
      },
      passByValue(val){
        this.user = val
      },
      handleEdit(index, row) {
        console.log(index, row);
      },
      handleDelete(index, row) {
        console.log(index, row);
      },



      uploading(){
        this.axios.post("/upload",this.qs.stringify(this.flower)).then(res => {
          if (res.data!=null||res.data!=''){
            this.$message.success('成功')
            this.flower=res.data
          }else{
            this.$message.error('失败')
          }
        })
      }



    },
    components:{ login},
    created(){
     this.$router.push("/home") //初始化就加入home页面
    }
  }
</script>
